import axios from 'axios';

var request = axios.create({
  baseURL: 'https://api.github.com', //基础路径
});

// 请求拦截
request.interceptors.request.use(
  (config) => {
    // 携带请求头参数
    config.headers['Authorization'] = localStorage.getItem('token');
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);

// 响应拦截
request.interceptors.response.use(
  (res) => {
    return res.data;
  },
  (error) => {
    return Promise.reject(error);
  }
);
export default request;
